<?php
$this->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
$this->headTitle()->setSeparator(' - ');
$this->headTitle('whichclub');

echo $this->doctype();
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <?php echo $this->render('partials/head.phtml'); ?>
    <!--
        Fancybox gallery
    -->
    <script type="text/javascript">
    $(document).ready(function() {
            $("a[rel=example_group]").fancybox({
                    'transitionIn'	: 'none',
                    'transitionOut'	: 'none',
                    'titlePosition' 	: 'over',
                    'titleFormat'	: function(title, currentArray, currentIndex, currentOpts) {
                            return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) 
                                + ' / ' + currentArray.length + (title.length ? ' '
                                + title : '') + '</span>';
                    }
            });
         });
    </script>

    <!--
        Google Maps
    -->
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <script type="text/javascript"
        src="http://maps.googleapis.com/maps/api/js?sensor=false">
    </script>

    <script type="text/javascript">
      var directionDisplay;
      var directionsService = new google.maps.DirectionsService();

      function initialize() {
        directionsDisplay = new google.maps.DirectionsRenderer();
        var myOptions = {
          zoom: 9,
          mapTypeId: google.maps.MapTypeId.ROADMAP,
          center: new google.maps.LatLng(<?php 
                                echo $this->escape($this->lat); 
                                          ?>,
                                         <?php
                                echo $this->escape($this->long);
                                          ?>)
        };

        var map = new google.maps.Map(document.getElementById('map_canvas'),
            myOptions);
/*
        var control = document.getElementById('control');
        control.style.display = 'block';
        map.controls[google.maps.ControlPosition.TOP].push(control);
*/
        directionsDisplay.setMap(map);

        // Try HTML5 geolocation
        if(navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(function(position) {
            pos = new google.maps.LatLng(position.coords.latitude,
                                             position.coords.longitude);

            var marker = new google.maps.Marker({
                position: pos,
                map: map,
                title: "Tu sei qui!"
            });

            //map.setCenter(pos);

        }, function() {
            handleNoGeolocation(true);
          });
        } else {
          // Browser doesn't support Geolocation
          handleNoGeolocation(false);
        }
        
        
        directionsDisplay.setPanel(document.getElementById('directions-panel'));

        var control = document.getElementById('control');
        control.style.display = 'block';
        control.style.left = '50px';
        map.controls[google.maps.ControlPosition.TOP].push(control);

      }

      function calcRoute() {
        var start = pos;
        var end = "<?php echo $this->escape($this->address) .
                                ", " . $this->escape($this->cap) .
                                        " " . $this->escape($this->paese); ?>";
        var request = {
          origin: start,
          destination: end,
          travelMode: google.maps.DirectionsTravelMode.DRIVING
        };
        directionsService.route(request, function(response, status) {
          if (status == google.maps.DirectionsStatus.OK) {
            directionsDisplay.setDirections(response);
          }
        });
      }

      function handleNoGeolocation(errorFlag) {
        if (errorFlag) {
          var content = 'Error: The Geolocation service failed.';
        } else {
          var content = 'Error: Your browser doesn\'t support geolocation.';
        }

        var options = {
          map: map,
          position: new google.maps.LatLng(45.5398382, 10.2229562), //brescia
          content: content
        };

        var infowindow = new google.maps.InfoWindow(options);
        map.setCenter(options.position);
      }

      google.maps.event.addDomListener(window, 'load', initialize);
    </script>
<script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-20565934-2']);
    _gaq.push(['_trackPageview']);

    (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
</script>

</head>

<body>
<div id="wrap">
            <div id="onda">
                <a class="onda_t"></a>
                <a class="onda_l"></a>
            </div>
    <!-- header -->
    <?php echo $this->render('partials/header.phtml'); ?>

    <div id="main">
        <div id="principal">
            <div id="side">
                <?php echo $this->layout()->side; ?>
                <div id="sponsor0">
                </div>
                <div id="sponsor1">
                 <?php //echo $this->layout()->sponsor1; ?>
                <div id="animationWrapper">
                      <a href="<?php
                                    echo $this->baseUrl() . '/contatti/organizza-serata'
                                        ?>">
                        <span class="span1">Organizza</span>
                        <span class="span2">la</span>
                        <span class="span3">tua</span>
                        <span class="span4">serata</span>
                      </a>
                </div>
                </div>
                <div id="sponsor2">
                    <?php //echo $this->layout()->sponsor2;
                        $url = "/contatti/informazioni/";
                        ?>
                    <div id="animationWrapper">
                          <a href="<?php
                                        echo $this->baseUrl() . $url;
                                            ?>">
                            <span class="span1">Aggiungi</span>
                            <span class="span2">il tuo locale</span>
                            <span class="span3">su whichclub,</span>
                            <span class="span4">E' GRATIS</span>
                          </a>
                    </div>
                </div>
                <div id="sponsor3">
                </div>
            </div>

            <div id="content">
                <!-- share menu -->
                <?php echo $this->render('partials/share-menu.phtml'); ?>

                <h1><?php echo $this->escape($this->title); ?></h1>
                <img src="<?php echo $this->escape($this->logo_club); ?>" alt="<?php
                    echo $this->escape($this->logo_alt); ?>" />
                <?php echo $this->layout()->content; ?>
                <?php
                    if($this->event!=null){
                        echo '<div id="event_c">';
                        echo '<a class="event" href="'. $this->url(array('controller'=>'Index',
                                                                               'action'=>'eventi',
                                                                               'id'=>$this->unique_name),
                                                                               'index',true)
                                    .'"><span class="event_sp"><br />&nbsp;EVENTI</span></a>';
                        echo '</div>';
                    }
                    if($this->categoria_club == 1){
                        echo '<div id="pren_tavolo">';
                        echo '<a class="tavolo" href="'. $this->url(array('controller'=>'Contact',
                                                                         'action'=>'prenota-tavolo'),
                                                                         'contact',true)
                                        .'"><span class="event_sp"><br />&nbsp;PRENOTA UN TAVOLO</span></a>';
                        echo '</div>';
                    }
                ?>
            </div>

            <div class="hr grid_12"></div>
            <div class="clear"></div>

            <div id="content_club">
                <?php echo $this->layout()->content2; ?>
                <div id="containar">
                <h4>Contatti</h4>
                <div id="contatti">
                    <table>
                        <tbody>
                            <tr>
                            <td id="address_club"></td><td><?php echo $this->escape($this->address) .
                                        ", " . $this->escape($this->cap) .
                                                " " . $this->escape($this->paese); ?></td>
                            </tr>
                            <tr>
                                <td id="phone_club"></td><td><?php echo html_entity_decode($this->tel); ?></td>
                            </tr>
                            <tr>
                                <td id="mail_club"></td><td><?php echo $this->escape($this->mail); ?></td>
                            </tr>
                            <tr>
                                <td id="url_club"></td><td><?php echo $this->escape($this->url); ?></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div id="control">
                    <button class="mappe" onclick="calcRoute();">Indicazioni stradali</button>
                </div>
                <div id="directions-panel"></div>
                <div id="map_canvas"></div>
            </div>
    </div>
    </div>

<!-- footer -->
<?php echo $this->render('partials/footer.phtml'); ?>

</div>

</div>

</body>
</html>